package com.krisyu.chainOfResponsibility.COR1;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @DATE 2022/1/5
 * @Author KrisYu
 * @Description
 */
public class Client {
    public static void main(String[] args) {
        Random random = new Random();
        List<Women> womenList = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            womenList.add(new Women(random.nextInt(5), "我要出去逛街"));
        }

        IHandler father = new Father();
        IHandler husband = new Husband();
        IHandler son = new Son();

        for (Women women : womenList) {
            if(women.getType() == 1){
                System.out.println("\n-------------女儿向父亲请示---------------");
                father.handleMessage(women);
            }else if(women.getType() == 2){
                System.out.println("\n-------------妻子向丈夫请示---------------");
                husband.handleMessage(women);
            }else if(women.getType() == 3){
                System.out.println("\n-------------母亲向儿子请示---------------");
                son.handleMessage(women);
            }else{
                System.out.println("\n-------------无人接受妇女的请示---------------");
            }
        }
    }
}
